<extend name="Public/base"/>
<block name="body">
<if condition="UID eq 1">
    <div class="row-content am-cf">
        <div class="row  am-cf">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-4">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title am-fl">月度财务收支计划</div>
                        <div class="widget-function am-fr">
                            <a href="javascript:;" class="am-icon-cog"></a>
                        </div>
                    </div>
                    <div class="widget-body am-fr">
                        <div class="am-fl">
                            <div class="widget-fluctuation-period-text">
                                ￥61746.45
                                <button class="widget-fluctuation-tpl-btn">
                                    <i class="am-icon-calendar"></i>
                                    更多月份
                                </button>
                            </div>
                        </div>
                        <div class="am-fr am-cf">
                            <div class="widget-fluctuation-description-amount text-success" am-cf>
                                +￥30420.56

                            </div>
                            <div class="widget-fluctuation-description-text am-text-right">
                                8月份收入
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                <div class="widget widget-primary am-cf">
                    <div class="widget-statistic-header">
                        本季度利润
                    </div>
                    <div class="widget-statistic-body">
                        <div class="widget-statistic-value">
                            ￥27,294
                        </div>
                        <div class="widget-statistic-description">
                            本季度比去年多收入 <strong>2593元</strong> 人民币
                        </div>
                        <span class="widget-statistic-icon am-icon-credit-card-alt"></span>
                    </div>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                <div class="widget widget-purple am-cf">
                    <div class="widget-statistic-header">
                        本季度利润
                    </div>
                    <div class="widget-statistic-body">
                        <div class="widget-statistic-value">
                            ￥27,294
                        </div>
                        <div class="widget-statistic-description">
                            本季度比去年多收入 <strong>2593元</strong> 人民币
                        </div>
                        <span class="widget-statistic-icon am-icon-support"></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</if>
<if condition="($member.group_id eq 9)">
     <div class="row-content am-cf" style="color: white">
        <div class="row  am-cf">
        <h2>您现在还未成为代理,请先购买成为代理吧</h2>
            
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                <div class="widget widget-primary am-cf">
                    <div class="widget-statistic-header">
                        一级代理可享受<font color="red">{$config.level1_rate|default="5.0"}</font>折房卡价格
                    </div>
                    <div class="widget-statistic-body">
                        <div class="widget-statistic-value">
                            ￥{$config.level1_price|default="100.00"}
                        </div>
                        <div class="widget-statistic-description">
                                <button class="widget-fluctuation-tpl-btn" onclick="pay(this)" id="1">
                                    <i class="am-icon-calendar"></i>
                                    点击购买，成为一级代理
                                </button>
                        </div>
                       
                    </div>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                <div class="widget widget-primary am-cf" style="background:black">
                    <div class="widget-statistic-header">
                        二级代理可享受<font color="red">{$config.level2_rate|default="7.0"}</font>折房卡价格
                    </div>
                    <div class="widget-statistic-body">
                        <div class="widget-statistic-value">
                            ￥{$config.level2_price|default="80.00"}
                        </div>
                        <div class="widget-statistic-description">
                                <button class="widget-fluctuation-tpl-btn" onclick="pay(this)" id="2">
                                    <i class="am-icon-calendar"></i>
                                    点击购买，成为二级代理
                                </button>
                        </div>
                       
                    </div>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                <div class="widget widget-purple am-cf">
                    <div class="widget-statistic-header">
                        三级代理可享受<font color="red">{$config.level3_rate|default="8.0"}</font>折房卡价格
                    </div>
                    <div class="widget-statistic-body">
                        <div class="widget-statistic-value">
                            ￥{$config.level3_price|default="60.00"}
                        </div>
                        <div class="widget-statistic-description">
                            <button class="widget-fluctuation-tpl-btn" onclick="pay(this)" id="3">
                                    <i class="am-icon-calendar"></i>
                                    点击购买，成为三级代理
                                </button>
                        </div>
                      
                    </div>
                </div>
            </div>
        </div>
         <div class='pay'>
            
            <img alt="支付" src="" style="width:200px;height:200px;"/>
         </div>
    </div>
</if>
<script>
        function pay(the){
            id = $(the).attr('id');
            $.ajax({
                url:'{:U("Member/pay")}',
                data:{id:id},
                type:'post',
                dataType:'json',
                success:function(data){
                  //  console.log(data.info.url);
                  if(data.status == 1){
                    var url='http://paysdk.weixin.qq.com/example/qrcode.php?data='+data.info.url
                    $('.pay').show();
                    $('.pay').find('img').attr('src',url)
                    //ajax获取订单状态
                    chkorder(data.info.order_sn);
                  } else if(data.status == 0){
                    layer.msg(data.info);
                  } else {
                    layer.msg(data.info);
                  }
                }
            })
        }

        function chkorder(order_sn){
            var clock = setInterval(function(){
                console.log(order_sn);
                $.ajax({
                    url:'{:U("Member/chkorder")}',
                    data:{order_sn:order_sn},
                    type:'get',
                    dataType:'json',
                    success:function(data){
                        if(data.status == 1){
                            clearInterval(clock);
                            layer.msg(data.info);
                              var timer = setInterval(function(){
                                  clearInterval(timer);
                                  window.location.href=data.url;
                              },2000);
                        }
                    }
                });
            },2000)

        }
</script>
</block>
